<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>微信带参数的二维码管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		
		function fillConfig(processorId,divId){
			$('#processorId').val(processorId);
			$('div .btn-success').addClass("btn-warning");;
			$('div .btn-success').removeClass("btn-success");;
			//去掉对号
			$('.right_sign').text("");
			//添加对号
			$('#right_'+divId).text("✔ ");;
			
			$('#processor_'+divId).addClass("btn-success");
			
			
		}
		
		
		/*
		function change(v){
			if(v==="QR_LIMIT_SCENE"){
				$("#QR_SCENE").hide();
			}
			if(v==="QR_SCENE"){
				$("#QR_SCENE").show();
			}
		
		}
			*/
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/wechat/wechatScene/">微信带参数的二维码列表</a></li>
		<li class="active"><a href="${ctx}/wechat/wechatScene/form?id=${wechatScene.id}">微信带参数的二维码<shiro:hasPermission name="wechat:wechatScene:edit">${not empty wechatScene.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:wechatScene:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="wechatScene" action="${ctx}/wechat/wechatScene/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<form:hidden path="processorId" /> 
		<tags:message content="${message}"/>
		
		<div class="control-group">
			<label class="control-label">场景:</label>
			<div class="controls">
				<form:input path="scene" htmlEscape="false" maxlength="11" class="required"/>    
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">业务处理器:</label>
			<div class="controls">
				<c:forEach items="${configList }" var="config">
									
					 <div class="row-fluid">
							<a href="javascript:fillConfig('${config.beanId }','${config.id }')">
								<div id="processor_${config.id }" class="span4 <c:if test="${ config.beanId eq wechatScene.processorId}">btn-success </c:if>    <c:if test="${ config.beanId ne wechatScene.processorId}">btn-warning </c:if>" >
								<span id="right_${config.id }"  class="right_sign"><c:if test="${ config.beanId eq wechatScene.processorId}">✔  </c:if></span>	
								<span id="content_${config.id }">${config.beanId } -- ${config.name }</span>
								
								</div>
							</a> 
			        </div>          
					          
				</c:forEach>   
			</div>
		</div>
		
		
		
		<div class="form-actions">
			<shiro:hasPermission name="wechat:wechatScene:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="生成"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
